package com.le.tester.book.concurrentchallenge.executorSelf;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

/**
 * createTime：2025-03-31 9:40
 * description：错误的timer行为
 */
public class OutOfTime {
    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        //单位1 mill
        timer.schedule(new ThrowTask(), 1);
        Thread.sleep(1000);

        timer.schedule(new ThrowTask(), 1);
        Thread.sleep(5000);
    }

    static class ThrowTask extends TimerTask {

        @Override
        public void run() {
            throw new RuntimeException();
        }
    }

}
